package com.yinkgh.mybatis.base.model;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.annotation.JSONField;
import com.yinkgh.mybatis.base.page.Page;

/**
 * 类名称: BaseModel 类描述: 分页模板类 创建人: wangshiping 创建时间: 2015年10月22日 上午9:13:06 修改人:
 * 修改时间: 修改备注:
 * 
 * @version v1.0.0
 * 
 */
public class BaseModel {
	@JSONField(serialize = false)
	private Integer page = 1;
	@JSONField(serialize = false)
	private Integer rows = 10;
	@JSONField(serialize = false)
	private String sort;
	@JSONField(serialize = false)
	private String order;
	@JSONField(serialize = false)
	private String pagination;// 是否分页

	/**
	 * 分页导航
	 */
	@JSONField(serialize = false)
	private Page pager = new Page();

	public Page getPager() {
		if (pagination != null && !pagination.equals("")) {
			if (pagination.equals("true")) {
				pager.setPaging(true);
			} else {
				pager.setPaging(false);
			}
		} else {
			pager.setPaging(true);
		}
		pager.setPageId(getPage());
		pager.setPageSize(getRows());
		if (StringUtils.isNotBlank(sort)) {
			pager.setOrderField(sort);
		}
		if (StringUtils.isNotBlank(order)) {
			pager.setOrderDirection(order);
		}
		return pager;
	}

	public void setPager(Page pager) {
		this.pager = pager;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public String getPagination() {
		return pagination;
	}

	public void setPagination(String pagination) {
		this.pagination = pagination;
	}

}
